package exam.huawei.string;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Scanner;

/**
 * @version 1.0.0
 * 给定一个元素类型为小写字符串的数组，请计算两个没有相同字符的元素长度乘积的最大值
 * 如果没有符合条件的两个元素，返回0
 */
public class Example03 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] strings = sc.nextLine().split(",");
        System.out.println(getResult(strings));
    }

    public static int getResult(String[] arr) {
        ArrayList<HashSet<Character>> list = new ArrayList<>();

        for (String s : arr) {
            HashSet<Character> set = new HashSet<>();
            for (char c : s.toCharArray()) set.add(c);
            list.add(set);
        }

        int ans = 0;

        for (int i = 0; i < list.size(); i++) {
            HashSet<Character> a = list.get(i);
            for (int j = i + 1; j < list.size(); j++) {
                HashSet<Character> b = list.get(j);
                // Collections.frequency(a, b) 取两个集合的交集的个数
                // Collections.disjoint(a, b) 如果没有交集返回true
                if (Collections.disjoint(a, b)) {
                    ans = Math.max(ans, arr[i].length() * arr[j].length());
                }
            }
        }

        return ans;
    }
}
